package com.data.modules.online.cgform.converter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.data.common.util.ConvertUtils;
import com.data.modules.online.cgform.entity.OnlCgformField;
import com.data.modules.online.cgform.util.CgformUtil;

public class ConvertUtil {

    public static final int f124a = 2;

    public static final int f125b = 1;

    public static void m131a(int i, List<Map<String, Object>> list, List<OnlCgformField> list2) {
        Map<String, FieldCommentConverter> a = ConvertFactory.m128a(list2);
        for (Map<String, Object> map : list) {
            HashMap hashMap = new HashMap();
            for (Map.Entry<String, Object> entry : map.entrySet()) {
                Object value = entry.getValue();
                if (value != null) {
                    String key = entry.getKey();
                    FieldCommentConverter fieldCommentConverter = a.get(key.toLowerCase());
                    if (fieldCommentConverter != null) {
                        String obj = value.toString();
                        String converterToTxt = i == 1 ? fieldCommentConverter.converterToTxt(obj) : fieldCommentConverter.converterToVal(obj);
                        if (converterToTxt == null) {
                            converterToTxt = obj;
                        }
                        m132a(fieldCommentConverter, map, i);
                        m133a(fieldCommentConverter, hashMap, obj);
                        map.put(key, converterToTxt);
                    }
                }
            }
            for (Object str : hashMap.keySet()) {
                map.put(str.toString(), hashMap.get(str));
            }
        }
    }

    private static void m132a(FieldCommentConverter fieldCommentConverter, Map<String, Object> map, int i) {
        Map<String, String> config = fieldCommentConverter.getConfig();
        if (config != null) {
            String str = config.get("linkField");
            if (ConvertUtils.isNotEmpty(str)) {
                String[] split = str.split(CgformUtil.f231E);
                for (String str2 : split) {
                    Object obj = map.get(str2);
                    if (obj != null) {
                        String obj2 = obj.toString();
                        map.put(str2, i == 1 ? fieldCommentConverter.converterToTxt(obj2) : fieldCommentConverter.converterToVal(obj2));
                    }
                }
            }
        }
    }

    private static void m133a(FieldCommentConverter fieldCommentConverter, Map<String, Object> map, String str) {
        Map<String, String> config = fieldCommentConverter.getConfig();
        if (config != null) {
            String str2 = config.get("treeText");
            if (ConvertUtils.isNotEmpty(str2)) {
                map.put(str2, str);
            }
        }
    }
}
